﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nuzzle.Managers
{
    public class BreedManager
    {
        public static Utilities.Settings BreedsSettings { get; set; }

        public static void Initialize()
        {
            BreedsSettings = new Utilities.Settings("Datas/Breeds.ini");
            BreedsSettings.ReadSettings();
        }

        public static BreedData GetBreedData(int id)
        {
            return new BreedData(
                BreedsSettings.GetIntElement(id + ".StartMap"),
                BreedsSettings.GetIntElement(id + ".StartCell"),
                BreedsSettings.GetStringElement(id + ".MaleColors"),
                BreedsSettings.GetStringElement(id + ".FemaleColors")
            );
        }

        public class BreedData
        {
            public int StartMap { get; set; }
            public int StartCell { get; set; }
            public List<int> MaleColors = new List<int>();
            public List<int> FemaleColors = new List<int>();

            public BreedData(int startmap, int startcell, string malecolors, string femalecolors)
            {
                this.StartMap = startmap;
                this.StartCell = startcell;
                foreach (var c in malecolors.Replace(" ", "").Split(','))
                {
                    if (c != "")
                    {
                        MaleColors.Add(int.Parse(c));
                    }
                }
                foreach (var c in femalecolors.Replace(" ", "").Split(','))
                {
                    if (c != "")
                    {
                        FemaleColors.Add(int.Parse(c));
                    }
                }
            }
        }
    }
}
